<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue-组件化的模板分离写法</title>
</head>

<body>
    <div id="app">
        <cpn1></cpn1>
        <cpn2></cpn2>
    </div>
    <!-- 最常用的是直接新建一个文件专门方组件 -->
    <!-- 1.通过script标签模板分离，注意：类型必须是 text/x-template-->
    <script type="text/x-template" id="cpn1">
        <div>
            <h2>我是标题111</h2>
            <p>我是内容111</p>
        </div>
    </script>

    <!-- 2.使用template标签模板分离 -->
    <template id="cpn2">
        <div>
            <h2>我是标题222</h2>
            <p>我是内容222</p>
        </div>
    </template>
    <script src="./js/vue.min.js"></script>
    <script>
        // 1.全局组件注册
        Vue.component('cpn1', {
            template: '#cpn1'
        })

        Vue.component('cpn2', {
            template: '#cpn2'
        })

        const app = new Vue({
            el: '#app',
            data: {
                message: '你好',
            },
            components: {}
        })
    </script>
</body>

</html>